/*
* Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
*/

#include "vpc_pipeline/dvpp_vpc_pipe.h"
#ifdef __KERNEL__
#include <linux/module.h>
#include "dvpp_sqe_gen.h"
#endif
#include "vpc_pipe_comm.h"

static dvpp_vpc_pipe_export_func_t *g_dvpp_vpc_pipe_export_func[VPC_PIPE_SUP_CHIP_END] = {NULL};

void dvpp_vpc_pipe_register_export_func(vpc_pipe_chip_type_e chip_type, dvpp_vpc_pipe_export_func_t *export_func)
{
    g_dvpp_vpc_pipe_export_func[chip_type] = export_func;
}

void dvpp_vpc_pipe_unregister_export_func(vpc_pipe_chip_type_e chip_type)
{
    g_dvpp_vpc_pipe_export_func[chip_type] = NULL;
}

#ifdef __KERNEL__
void dvpp_vpc_pipe_init_export_func(void)
{
    vpc_pipe_register_mlv1r3_export_func();
    g_dvpp_vpc_pipe_export_func[VPC_PIPE_MINI_V2]->pfn_dvpp_gen_vpc_sqe = dvpp_gen_vpc_sqe;
}

void dvpp_vpc_pipe_uninit_export_func(void)
{
    vpc_pipe_unregister_mlv1r3_export_func();
}

dvpp_vpc_pipe_export_func_t* dvpp_vpc_pipe_get_export_func()
{
    return g_dvpp_vpc_pipe_export_func[VPC_PIPE_MINI_V2];
}
EXPORT_SYMBOL_GPL(dvpp_vpc_pipe_get_export_func);
#else // #ifdef __KERNEL__
static void  __attribute__((constructor)) dvpp_vpc_pipe_init_export_func(void)
{
    vpc_pipe_register_mlv1r3_export_func();
    vpc_pipe_register_mlv1r1_export_func();
}

static void  __attribute__((destructor)) dvpp_vpc_pipe_uninit_export_func(void)
{
    vpc_pipe_unregister_mlv1r3_export_func();
    vpc_pipe_unregister_mlv1r1_export_func();
}

dvpp_vpc_pipe_export_func_t* dvpp_vpc_pipe_get_export_func(vpc_pipe_chip_type_e chip_type)
{
    return g_dvpp_vpc_pipe_export_func[chip_type];
}
#endif // #ifdef __USER__
